clear			all
set 			more off
cd 				"~/Dropbox/Indonesia Migration/" // Specify your root directory here
/*******************************************************************************
				Employment
********************************************************************************/
use				"Data/Merged", clear
label 			var per_immig_cst_5Y "Population share of new migrants in year t"
label 			var per_immig_cst_5Y_lag "Population share of new migrants in year t-5"

foreach 		var in emp native_emp mig_emp_o mig_emp_n {
replace			prop_`var' = prop_`var' * 100
}
/*******************************************************************************
				Conventional shift-share instrument
********************************************************************************/
quietly ivreg2 prop_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first			
eststo p1

quietly ivreg2	prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first				
eststo p2
				
quietly ivreg2	prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first				
eststo p3
				
quietly ivreg2	prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first				
eststo p4
				
coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.5) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.5) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.5) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.5) ciopts(recast(rcap) lcolor(black))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) leg(off) /// 
xlabel(-1.5 `" "All" "People" "' -0.5 "Natives" 0.5 `" "Old" "Migrants" "' 1.5 `" "New" "Migrants" "', /// 
noticks labsize(small)) ytitle("Impact on employment in year {it:t}") /// 
title("{bf:Panel A:} Shift-share instrument using {it:t-5} migration settlement", size(small)) /// 
xsize(8) ysize(8) leg(off) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T4_employment_t5.jpg", as(jpg) name("Graph") quality(100) replace

/*******************************************************************************
				Shift-share instrument with 10-year lag
********************************************************************************/
quietly ivreg2	prop_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first			
eststo p1
				
quietly ivreg2	prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first				
eststo p2
				
quietly ivreg2	prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first				
eststo p3
				
quietly ivreg2	prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first				
eststo p4

coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.5) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.5) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.5) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.5) ciopts(recast(rcap) lcolor(black))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) leg(off) /// 
xlabel(-1.5 `" "All" "People" "' -0.5 "Natives" 0.5 `" "Old" "Migrants" "' 1.5 `" "New" "Migrants" "', /// 
noticks labsize(small)) ytitle("Impact on employment in year {it:t}") /// 
title("{bf:Panel B:} Shift-share instrument using {it:t-10} migration settlement", size(small)) /// 
xsize(8) ysize(8) leg(off) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T4_employment_t10.jpg", as(jpg) name("Graph") quality(100) replace
		
/*******************************************************************************
				Multiple lag instrument
********************************************************************************/
quietly ivreg2	prop_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p1
				
quietly ivreg2	prop_native_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p2
				
quietly ivreg2	prop_mig_emp_o (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p3

quietly ivreg2	prop_mig_emp_n (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev2) first	
eststo p4

coefplot (p1, keep(per_immig_cst_5Y) mcolor(black) offset(-2.6) ciopts(recast(rcap) lcolor(black))) ///
(p1, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-3.4) ciopts(recast(rcap) lcolor(navy))) ///
(p2, keep(per_immig_cst_5Y) mcolor(black) offset(-1.6) ciopts(recast(rcap) lcolor(black))) ///
(p2, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-2.4) ciopts(recast(rcap) lcolor(navy))) ///
(p3, keep(per_immig_cst_5Y) mcolor(black) offset(-0.6) ciopts(recast(rcap) lcolor(black))) ///
(p3, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-1.4) ciopts(recast(rcap) lcolor(navy))) ///
(p4, keep(per_immig_cst_5Y) mcolor(black) offset(0.6) ciopts(recast(rcap) lcolor(black))) ///
(p4, keep(per_immig_cst_5Y_lag) msymbol(S) mcolor(navy) offset(-0.2) ciopts(recast(rcap) lcolor(navy))), ///
vertical yline(0, lpattern (dash) lcolor(red)) scheme(s1color) /// 
xlabel(-1.5 `" "All" "People" "' -0.5 "Natives" 0.5 `" "Old" "Migrants" "' 1.5 `" "New" "Migrants" "', /// 
noticks labsize(small)) ytitle("Impact on employment") xsize(12) ysize(8) /// 
title("{bf:Panel C:} Multiple instruments using {it:t-10} migration settlement", size(small)) ///
legend(order(2 "Share of new migrants in year {it:t}" 4 "Share of new migrants in year {it:t-5}")) /// 
graphregion(margin(2 4 2 2)) xscale(r(-2 2) noextend titlegap(2)) yscale(titlegap(2))

graph export "Coefplots/T4_employment_mt10.jpg", as(jpg) name("Graph") quality(100) replace





















